package Logic;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;

import javax.swing.JOptionPane;

import Messages.MessageAddAsingment;
import Messages.MessageAddBusiness;
import Messages.MessageAddFlower;
import Messages.MessageAddPrivate;
import Messages.MessageAddRaw;
import Messages.MessageAddSupplier;
import Messages.MessageAddUser;
import Messages.MessageAddVase;
import Messages.MessageDeleteAssigmn;
import Messages.MessageDeleteBusiness;
import Messages.MessageDeleteOrder;
import Messages.MessageDeletePrivate;
import Messages.MessageDeleteRaw;
import Messages.MessageDeleteSupp;
import Messages.MessageDeleteFlower;
import Messages.MessageDeleteVase;
import Messages.MessageEditBussines;
import Messages.MessageEditOrder;
import Messages.MessageEditPrivate;
import Messages.MessageEditSupplier;
import Messages.MessageFlowerInv;
import Messages.MessageGetAssigmnInfo;
import Messages.MessageGetRentBuss;
import Messages.MessageInventoryForm;
import Messages.MessageLogin;
import Messages.MessageLogout;
import Messages.MessageMakeFlowerUpdate;
import Messages.MessageMakeOrderUpdate;
import Messages.MessageMakeRawUpdate;
import Messages.MessageMakeVaseUpdate;
import Messages.MessageOrder;
import Messages.MessageOrderReport;
import Messages.MessagePullPrivate;
import Messages.MessagePullSupp;
import Messages.MessageRawInv;
import Messages.MessageRentPerCustomerReport;
import Messages.MessageSaleReport;
import Messages.MessageSearchBussines;
import Messages.MessageSearchOrder;
import Messages.MessageSearchPhone;
import Messages.MessageSearchPrivate;
import Messages.MessageShowAssignment;
import Messages.MessageShowSuppliers;
import Messages.MessageUpdateFlower;
import Messages.MessageUpdateRaw;
import Messages.MessageUpdateSupp;
import Messages.MessageUpdateVase;
import Messages.MessageVaseInv;
import Messages.MessagepullBusiness;
import ocsf.server.ConnectionToClient;
/**
 * This class is the main class thats connect between the server and the client 
 * This class gets a msg and select the correct case and create a class that 
 * take an information from the DB 
 * @author Gabi Revah
 * @author Aviad Almog
 */
public class TaskAssignment {
	
	ConnectionToClient client;
/**
 * This method gets an msg and selecting by the first word of the msg the correct case 	 
 * @param msg
 * @param client
 * @throws SQLException
 * @throws IOException
 */
	public TaskAssignment(Object msg, ConnectionToClient client) throws SQLException, IOException 
	{
		
		  String[] str;
		  msg= msg.toString().substring(1, msg.toString().length()-1); // remove the [] from the msg by substring 
		  str = msg.toString().split("[ , ] "); // remove the , from msg and splitting it to tiny str array parts  
		  
		  
		  switch(str[0])
	      {          
			      case ("Login"):
				  {
					
			    	  MessageLogin login =  new MessageLogin(str, client);  
			    	  login.Authorization();
					  
			      break;
				  }//end of case
			      
			      case ("Logout"):
			      {
			    		
			    	  MessageLogout ml =  new MessageLogout(str, client);  
			    	  ml.Logout(str[1],str[2]);
			    	  break;
			      }
			      case ("AddUser"):
			      {
			    		
			    	  MessageAddUser AddUser =  new MessageAddUser(str, client);  
			    	  AddUser.AddUser();
			    	  break;
			      }
			      case ("AddBusiness"):
			      {
			    		
			    	  MessageAddBusiness AddBusiness =  new MessageAddBusiness(str, client);  
			    	  AddBusiness.AddBusiness();
			    	  break;
			      }
			      case ("AddPrivate"):
			      {
			    		
			    	  MessageAddPrivate AddPrivate =  new MessageAddPrivate(str, client);  
			    	  AddPrivate.AddPrivate();
			    	  break;
			      }
			      case ("Order"):
			      {
			    		
			    	  MessageOrder Order =  new MessageOrder(str, client);  
			    	  Order.Order();
			    	  break;
			      }
			      case ("AddAsingment"):
			      {
			    		
			    	  MessageAddAsingment AddAsingment =  new MessageAddAsingment(str, client);  
			    	  AddAsingment.AddAsingment();
			    	  break;
			      }
			      case ("SearchOrder"):
			      {
			    		
			    	  MessageSearchOrder SearchOrder =  new MessageSearchOrder(str, client);  
			    	  SearchOrder.SearchOrder();
			    	  break;
			      }
			      case ("DeleteOrder"):
			      {	
			    	  MessageDeleteOrder DeleteOrder =  new MessageDeleteOrder(str, client);  
			    	  DeleteOrder.DeleteOrder();
			    	  break;
			      }
			      case ("EditOrder"):
			      {	
			    	  MessageEditOrder EditOrder =  new MessageEditOrder(str, client);  
			    	  EditOrder.EditOrder();
			    	  break;
			      }
			      case ("SearchPrivate"):
			      {	
			    	  MessageSearchPrivate SearchPrivate =  new MessageSearchPrivate(str, client);  
			    	  SearchPrivate.SearchPrivate();
			    	  break;
			      }
			      case ("DeletePrivate"):
			      {	
			    	  MessageDeletePrivate DeletePrivate =  new MessageDeletePrivate(str, client);  
			    	  DeletePrivate.DeletePrivate();
			    	  break;
			      }
			      case ("EditPrivate"):
			      {	
			    	  MessageEditPrivate EditPrivate =  new MessageEditPrivate(str, client);  
			    	  EditPrivate.EditPrivate();
			    	  break;
			      }
			      case ("EditSupplier"):
			      {	
			    	  MessageEditSupplier EditSupplier =  new MessageEditSupplier(str, client);  
			    	  EditSupplier.EditSupplier();
			    	  break;
			      }
			      case ("SearchBussines"):
			      {	
			    	  MessageSearchBussines SearchBussines =  new MessageSearchBussines(str, client);  
			    	  SearchBussines.SearchBussines();
			    	  break;
			      }
			      case ("EditBussiness"):
			      {	
			    	  MessageEditBussines EditBussines =  new MessageEditBussines(str, client);  
			    	  EditBussines.EditBussines();
			    	  break;
			      }
			      case ("DeleteBussiness"):
			      {	
			    	  MessageDeleteBusiness DeleteBusiness =  new MessageDeleteBusiness(str, client);  
			    	  DeleteBusiness.DeleteBusiness();
			    	  break;

			      }
			      case ("SearchPhone"):
			      {	
			    	  MessageSearchPhone SearchPhone =  new MessageSearchPhone(str, client);  
			    	  SearchPhone.SearchPhone();
			    	  break;
			      }
			      case ("ShowAssign"):
			      {	
			    	  MessageShowAssignment ShowAssignment =  new MessageShowAssignment(str, client);  
			    	  ShowAssignment.ShowAssign();
			    	  break;
			      }
			      case ("ShowSupp"):
			      {	
			    	  MessageShowSuppliers ShowSupp =  new MessageShowSuppliers(str, client);  
			    	  ShowSupp.ShowSupp();
			    	  break;
			      }
			      case ("AddSupp"):
			      {	
			    	  MessageAddSupplier AddSupp =  new MessageAddSupplier(str, client);  
			    	  AddSupp.AddSupplier();
			    	  break;
			      }
			      case ("updateSupp"):
			      {	
			    	  
			    	  MessageUpdateSupp UpdateSupp =  new MessageUpdateSupp(str, client);  
			    	  UpdateSupp.UpdateSupp();
			    	  break;
			      }
			      case ("DeleteSupp"):
			      {	
			    	  
			    	  MessageDeleteSupp DeleteSupp =  new MessageDeleteSupp(str, client);  
			    	  DeleteSupp.DeleteSupp();
			    	  break;
			      }
			      case ("FlowerInv"):
			      {	
			    	  
			    	  MessageFlowerInv FlowerInv =  new MessageFlowerInv(str, client);  
			    	  FlowerInv.FlowerInv();
			    	  break;
			      }
			      case ("pullSupp"):
			      {	
			    	  
			    	  MessagePullSupp pullSupp =  new MessagePullSupp(str, client);  
			    	  pullSupp.PullSupp();
			    	  break;
			      }
			      case ("AddFlower"):
			      {	
			    	  
			    	  MessageAddFlower AddFlower =  new MessageAddFlower(str, client);  
			    	  AddFlower.AddFlower();
			    	  break;
			      }
			      case ("UpdateFlower"):
			      {	
			    	  
			    	  MessageUpdateFlower UpdateFlower =  new MessageUpdateFlower(str, client);  
			    	  UpdateFlower.UpdateFlower();
			    	  break;
			      }	
			      case ("MakeFlowerUpdate"):
			      {	
			    	  
			    	  MessageMakeFlowerUpdate MakeFlowerUpdate =  new MessageMakeFlowerUpdate(str, client);  
			    	  MakeFlowerUpdate.MakeFlowerUpdate();
			    	  break;
			      }
			      case ("DeleteFlower"):
			      {	
			    	  
			    	  MessageDeleteFlower DeleteFlower =  new MessageDeleteFlower(str, client);  
			    	  DeleteFlower.DeleteFlower();
			    	  break;
			      }
			      case ("VaseInv"):
			      {	
			    	  
			    	  MessageVaseInv VaseInv =  new MessageVaseInv(str, client);  
			    	  VaseInv.VaseInv();
			    	  break;
			      }
			      case ("AddVase"):
			      {	
			    	  
			    	  MessageAddVase AddVase =  new MessageAddVase(str, client);  
			    	  AddVase.AddVase();
			    	  break;
			      }
			      case ("UpdateVase"):
			      {	
			    	  
			    	  MessageUpdateVase UpdateVase =  new MessageUpdateVase(str, client);  
			    	  UpdateVase.UpdateVase();
			    	  break;
			      }	
			      case ("MakeVaseUpdate"):
			      {	
			    	  
			    	  MessageMakeVaseUpdate MakeVaseUpdate =  new MessageMakeVaseUpdate(str, client);  
			    	  MakeVaseUpdate.MakeVaseUpdate();
			    	  break;
			      }
			      case ("DeleteVase"):
			      {	
			    	  
			    	  MessageDeleteVase DeleteVase =  new MessageDeleteVase(str, client);  
			    	  DeleteVase.DeleteVase();
			    	  break;
			      }
			      case ("RawInv"):
			      {	
			    	  
			    	  
			    	  MessageRawInv RawInv =  new MessageRawInv(str, client);  
			    	  RawInv.RawInv();
			    	  break;
			      }
			      case ("AddRaw"):
			      {	
			    	  
			    	  MessageAddRaw AddRaw =  new MessageAddRaw(str, client);  
			    	  AddRaw.AddRaw();
			    	  break;
			      }
			      case ("UpdateRaw"):
			      {	
			    	  
			    	  MessageUpdateRaw UpdateRaw =  new MessageUpdateRaw(str, client);  
			    	  UpdateRaw.UpdateRaw();
			    	  break;
			      }
			      case ("MakeRawUpdate"):
			      {	
			    	  
			    	  MessageMakeRawUpdate MakeRawUpdate =  new MessageMakeRawUpdate(str, client);  
			    	  MakeRawUpdate.MakeRawUpdate();
			    	  break;
			      }
			      case ("DeleteRaw"):
			      {	
			    	  
			    	  MessageDeleteRaw DeleteRaw =  new MessageDeleteRaw(str, client);  
			    	  DeleteRaw.DeleteRaw();
			    	  break;
			      }
			      
			      case ("OrderReport"):
			      {	
			    	  
			    	  MessageOrderReport OrderReport =  new MessageOrderReport(str, client);  
			    	  OrderReport.OrderReport();
			    	  break;
			      }
			      case ("SaleReport"):
			      {	
			    	  
			    	  MessageSaleReport SaleReport =  new MessageSaleReport(str, client);  
			    	  SaleReport.SaleReport();
			    	  break;
			      }
			      case ("InventoryForm"):
			      {	

			    	  MessageInventoryForm InventoryForm =  new MessageInventoryForm(str, client);  
			    	  InventoryForm.InventoryForm(str[2],str[1],str[3],str[4]);
			    	  break;
			      }
			      case ("MakeOrderUpdate"):
			      {	
			    	  
			    	  MessageMakeOrderUpdate MakeOrderUpdate= new MessageMakeOrderUpdate(str, client);
			    	  MakeOrderUpdate.MakeOrderUpdate();
			    	  break;
			      }
			      case ("GetAssigmnInfo"):
			      {	
			    	  
			    	  
			    	  MessageGetAssigmnInfo GetAssigmnInfo= new MessageGetAssigmnInfo(str, client);
			    	  GetAssigmnInfo.GetAssigmnInfo();
			    	  break;
			      }
			      case ("DeleteAssigmn"):
			      {	
			    	  
			    	  
			    	  MessageDeleteAssigmn DeleteAssigmn= new MessageDeleteAssigmn(str, client);
			    	  DeleteAssigmn.DeleteAssigmn();
			    	  break;
			      }
			      case ("GetRentBuss"):
			      {	
			    	  
			    	  
			    	  MessageGetRentBuss GetRentBuss= new MessageGetRentBuss(str, client);
			    	  GetRentBuss.GetRentBuss();
			    	  break;
			      }
			      case ("rpcr"):
			      {	
			    	  MessageRentPerCustomerReport RentPerCustomerReport= new MessageRentPerCustomerReport(str, client);
			    	  RentPerCustomerReport.RentPerCustomerReport();
			    	  break;
			      }
			      case ("pullPrivate"):
			      {	
			    	  
			    	  
			    	  MessagePullPrivate PullPrivate= new MessagePullPrivate(str, client);
			    	  PullPrivate.PullPrivate();
			    	  break;
			      }
			      case ("pullBusiness"):
			      {	
			    	  
			    	  
			    	  MessagepullBusiness pullBusiness= new MessagepullBusiness(str, client);
			    	  pullBusiness.pullBusiness();
			    	  break;
			      }
			      
	      }//end of switch
		  
		  
		  
	}//end of TaskAssignment



}//end of class

	